[][src]Crate cqrs_es

cqrs

A lightweight, opinionated CQRS and event sourcing framework targeting serverless architectures.

Build tag Crates.io docs

Installation

cqrs-es is available from Crates.io or Github.

[dependencies]
cqrs-es = "0.0.13"

Opinions

  • Aggregate persistence is via event sourcing only.
  • Metadata is implemented only as a HashMap<String,String>. Further, the MetadataSupplier that the user provides has no insight into the event or aggregate that it supplies metadata for. This may be changed.
  • JSON serialization only.
  • Generics are preferred over boxed traits.
  • Persistence is implemented through a Postgres database.

Todos/research

  • Event upcasters.
  • Explore options for increasing the usefulness of MetadataSupplier.
  • Event serialization uses the event type as the root node of the JSON tree. This simplifies deserialization but is non-standard.
  • Persistence implementation for DynamoDb.

Modules

mem_store

An in-memory event store suitable for local testing.

test

Test provides a test framework for building a resilient test base around aggregates.

Structs

CqrsFramework

This is the base framework for applying commands to produce events.

MessageEnvelope

MessageEnvelope is a data structure that encapsulates an event with along with it's pertinent information. All of the associated data will be transported and persisted together.

UserErrorPayload

Payload for an AggregateError::UserError, somewhat modeled on the errors produced by the (validator)[https://github.com/Keats/validator] package. This payload implements Serialize with the intention of allowing the user to return this object as the response payload.

Enums

AggregateError

The base error for the framework.

Traits

Aggregate

A trait that defines an Aggregate, the fundamental component in CQRS that encapsulates the state and business logic for the application. An Aggregate is always an entity along with all objects associated with it.

Command

A Command represents a request to modify the state of an Aggregate by producing DomainEvents.

DomainEvent

A DomainEvent represents any business change in the state of an Aggregate. DomainEvents are immutable and with event sourcing they are the source of truth.

EventStore

The abstract central source for loading past events and committing new events.

Query

Downstream Querys are the read elements in a CQRS system. As events are emitted these queries , or views, are updated to reflect the currente state of the system.

QueryProcessor

Each CQRS platform should have one or more QueryProcessors where it will distribute committed events, it is the responsibility of the QueryProcessor to update any interested queries.